#include "mini.kit.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

int32_t main(int32_t argc, char* argv[])
{
	if(argc<2)
	{
		fprintf(stderr,"usage: %s need_gbk_to_utf8\n", argv[0]);
		fprintf(stderr,"example: %s 1 \n", argv[0]);
		return 1;
	}
	
	int32_t need_GBKToUTF8 = atoi(argv[1]);
	char buff[4096];
	std::string sLine;
	std::string sLineEncoded;
	while(!std::cin.eof())
	{
		std::cin.getline(buff, sizeof(buff));
		sLine = buff;
		if( !sLine.empty() ) sLine = sLine + "\n";
		if(need_GBKToUTF8)
			MINIKIT::Text::conv_gbk_utf8(sLine);
		MINIKIT::Text::escape(sLine, sLineEncoded);
		std::cout << sLineEncoded; 
	}
	return 0;
}

